<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ page import="javabean.Conn" %>
    <%@ page import="java.sql.*" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>add_deal</title>
</head>
<body>
<jsp:useBean id="user" class="javabean.User"></jsp:useBean>
<jsp:setProperty property="*" name="user"></jsp:setProperty>
<%
try{
	Connection conn=Conn.connect();
	String selectsql="select * from wuqiantong where name=?";
	PreparedStatement ps0=conn.prepareStatement(selectsql);
	ps0.setString(1,user.getName());
	ResultSet rs=ps0.executeQuery();
	if(rs.next()){
		out.print("This student's information already exists.");
	}
	else{
	String insertsql="insert into wuqiantong (name,interest,password)values(?,?,?)";
	PreparedStatement ps=conn.prepareStatement(insertsql);
	ps.setString(1, user.getName());
	ps.setString(2,user.getInterest());
	ps.setString(3,user.getPassword());
	int row=ps.executeUpdate();
	if(row>0){
		out.print("Add successfully!");
	}
	ps.close();
	}
	ps0.close();
	conn.close();
}
catch(Exception e){
	e.printStackTrace();
	out.print("Add failed.");
}
%>
<a href="add.jsp">back</a>
<a href="adminMain.jsp">adminMain</a>
</body>
</html>